<?php

namespace app\api\model;

use think\Model;

class QuestionsAnswers extends Model
{
    public static function getQuestionAnswerByQid($qid)
    {
        $list = self::where(['qid' => $qid])
            ->order('id desc')
            ->select()
            ->toArray();
        $correct = [];
        $data = [];
        foreach ($list as $key => $item) {
            if ($item['correct']) $correct[] = chr($key + 65);
            $data[] = [
                'value' => chr($key + 65),
                'label' => $item['title'],
            ];
        }
        return [$data, $correct];
    }
}